Overrides a nkTasks::Task to be able to use it within a Lua environment. More...
Public Member Functions | |
UbyteArrayData * | getInputBinaryData () const |
UbyteArrayData * | getOutputBinaryData () const |
void | setWorkFuncReference (const nkScripts::ScriptObjectReference &reference) |
void | setInitScript (nkScripts::Script *script) |
void | setInputBinaryData (UbyteArrayData *data, const nkScripts::ScriptObjectReference &ref) |
void | setOutputBinaryData (UbyteArrayData *data) |
void | addInputUserData (void *ptr, const nkMemory::StringView &typeName, bool owner) |
void | addOutputUserData (void *ptr, const nkMemory::StringView &typeName, bool owner) |
const UserDataHolder * | getInputUserData (unsigned int index) const |
const UserDataHolder * | getOutputUserData (unsigned int index) const |
![]() | |
Task () | |
virtual | ~Task () |
Thread * | getParentThread () const |
TASK_RESULT | getWorkResult () const |
void | setParentThread (Thread *thread) |
void | setWorkResult (TASK_RESULT result) |
virtual TASK_RESULT | onWork ()=0 |
virtual void | onWorkDone ()=0 |
virtual void | onSuccess ()=0 |
virtual void | onFail ()=0 |
virtual void | onAbort ()=0 |
Overrides a nkTasks::Task to be able to use it within a Lua environment.
Symbols are not exported, this class is not meant to be used as is from the C++ code, but rather from the scripting environment. Documented functions are available in the environment through TaskWrapper.
Within Lua, threads are not allowed. See LuaThread for more details. As such, memory management within tasks has to be done cautiously. Be sure to manage correctly user data ownership when passing them around. Lua objects need to be serialized before being communicated. Typically :
If ownership of user data has to be passed around, use serializeForwardOwnership().
UbyteArrayData* nkAstraeus::lua::nkTasksWrap::LuaTask::getInputBinaryData | ( | ) | const |
UbyteArrayData* nkAstraeus::lua::nkTasksWrap::LuaTask::getOutputBinaryData | ( | ) | const |
void nkAstraeus::lua::nkTasksWrap::LuaTask::setWorkFuncReference | ( | const nkScripts::ScriptObjectReference & | reference | ) |
Sets the work function to use, through a reference within the calling thread. This function will be executed when the task is submitted for work.
reference | The reference to the function. |
void nkAstraeus::lua::nkTasksWrap::LuaTask::setInitScript | ( | nkScripts::Script * | script | ) |
Sets the script to run once when launching the task. This will be run before the work function. Such a script can be used to set up some variables within the work thread before working on it.
script | The script to execute as an initialization step. |
void nkAstraeus::lua::nkTasksWrap::LuaTask::setInputBinaryData | ( | UbyteArrayData * | data, |
const nkScripts::ScriptObjectReference & | ref | ||
) |
Allows to set binary data, marking it as input. Binary data will be available in the work thread, and is supposed to be alive in the calling thread.
data | The data to use as input. |
ref | The reference of the buffer, to prevent garbage collection. |
void nkAstraeus::lua::nkTasksWrap::LuaTask::setOutputBinaryData | ( | UbyteArrayData * | data | ) |
Allows to set binary data, marking it as output. The data will be copied so that a reference can be kept alive within the calling thread.
data | The data to link as output data. |
void nkAstraeus::lua::nkTasksWrap::LuaTask::addInputUserData | ( | void * | ptr, |
const nkMemory::StringView & | typeName, | ||
bool | owner | ||
) |
Adds a user data as an input for the task.
ptr | The user data pointer. |
typeName | The user type name of the data. |
owner | Whether the script environment retrieving the data should become owner of the data (true) or not (false). |
void nkAstraeus::lua::nkTasksWrap::LuaTask::addOutputUserData | ( | void * | ptr, |
const nkMemory::StringView & | typeName, | ||
bool | owner | ||
) |
Adds a user data as an output for the task.
ptr | The user data pointer. |
typeName | The user type name of the data. |
owner | Whether the script environment retrieving the data should become owner of the data (true) or not (false). |
const UserDataHolder* nkAstraeus::lua::nkTasksWrap::LuaTask::getInputUserData | ( | unsigned int | index | ) | const |
index | The index of the user data to retrieve. |
const UserDataHolder* nkAstraeus::lua::nkTasksWrap::LuaTask::getOutputUserData | ( | unsigned int | index | ) | const |
index | The index of the user data to retrieve. |